import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 模具仓库信息 */
export interface Warehouse {
  id: number // 仓库id
  status?: number // 状态
  code: string // 编码
  name?: string // 名称
  type?: number // 类型id
  description: string // 备注
}

// 模具仓库 API
export const WarehouseApi = {
  // 查询模具仓库列表
  getWarehouses: async () => {
    return await request.get({ url: `/mold/warehouse/all` })
  },

  // 查询模具仓库分页
  getWarehousePage: async (params: any) => {
    return await request.get({ url: `/mold/warehouse/page`, params })
  },

  // 查询模具仓库详情
  getWarehouse: async (id: number) => {
    return await request.get({ url: `/mold/warehouse/get?id=` + id })
  },

  // 新增模具仓库
  createWarehouse: async (data: Warehouse) => {
    return await request.post({ url: `/mold/warehouse/create`, data })
  },

  // 修改模具仓库
  updateWarehouse: async (data: Warehouse) => {
    return await request.put({ url: `/mold/warehouse/update`, data })
  },

  // 删除模具仓库
  deleteWarehouse: async (id: number) => {
    return await request.delete({ url: `/mold/warehouse/delete?id=` + id })
  },

  /** 批量删除模具仓库 */
  deleteWarehouseList: async (ids: number[]) => {
    return await request.delete({ url: `/mold/warehouse/delete-list?ids=${ids.join(',')}` })
  },

  // 导出模具仓库 Excel
  exportWarehouse: async (params) => {
    return await request.download({ url: `/mold/warehouse/export-excel`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/mold/warehouse/get-import-template' })
  }
}
